<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:gs="http://java.sun.com/jsf/composite/gs"
	template="/WEB-INF/templates/default.xhtml">
	<ui:define name="menu">
		<ui:include src="/protected/user/menu.xhtml" >
			<ui:param name="activeMenu" value="cliente" />
			<ui:param name="activeSubMenu" value="personaFisica" />
		</ui:include>		
	</ui:define>	
	<ui:define name="breadcrumb">
		<ui:include src="breadcrumbIndex.xhtml" />
	</ui:define>
	<ui:define name="content">	
		<h:form id="form-search" styleClass="well form-horizontal">
			<div class="control-group">
	    		<h:outputLabel value="#{messages.personaNumeroDocumento}:"  
   					for="numeroDocumento" 
   					styleClass="control-label"/>
		    	<h:selectOneMenu id="tipoDocumento"
		    		style="margin-left:5px;" 
		    		value="#{personaFisicaSearchingBean.filter.tipoDocumento}">
		    		<f:selectItem itemLabel="#{messages.ingresarValor}" 
		    			noSelectionOption="true"/>
		    		<f:selectItems value="#{enumRefereceBean.tiposDocumentos}"/>
		    	</h:selectOneMenu>
				<h:inputText id="numeroDocumento"
					style="margin-left:5px;"
					value="#{personaFisicaSearchingBean.filter.numeroDocumento}"
					placeholder="#{messages.personaNumeroDocumento}"
					styleClass="input-medium search-query">
				</h:inputText>
			</div>
			<div class="control-group">
				<h:outputLabel value="#{messages.personaSearchNombres}:"  
					styleClass="control-label"/>
				<h:inputText id="primeroNombre" 
					style="margin-left:5px;"
					value="#{personaFisicaSearchingBean.filter.primerNombre}"
					placeholder="#{messages.personaPrimerNombre}"
					styleClass="input-medium">
				</h:inputText>
				<h:inputText id="segundoNombre" 
					style="margin-left:5px;"
					value="#{personaFisicaSearchingBean.filter.segundoNombre}"
					placeholder="#{messages.personaSegundoNombre}"
					styleClass="input-medium">
				</h:inputText>
			</div>
			<div class="control-group">
				<h:outputLabel value="#{messages.personaSearchApellidos}:"  
					styleClass="control-label"/>
				<h:inputText id="apellido1" 
					style="margin-left:5px;"
					value="#{personaFisicaSearchingBean.filter.apellido1}"
					placeholder="#{messages.personaApellido1}"
					styleClass="input-medium">
				</h:inputText>
				<h:inputText id="apellido2" 
					style="margin-left:5px;"
					value="#{personaFisicaSearchingBean.filter.apellido2}"
					placeholder="#{messages.personaApellido2}"
					styleClass="input-medium">
				</h:inputText>
			</div>
			<div class="control-group">
				<h:outputLabel value=""  
					styleClass="control-label"/>
				<gs:buttonSearch bean="#{personaFisicaSearchingBean}"/>
			</div>
		</h:form>

		<h:form id="form-content">
			<rich:dataTable value="#{personaFisicaSearchingBean.dataModel}"
				styleClass="table table-bordered table-striped table-condensed"
				columnClasses="pf-sc-1,pf-sc-2,pf-sc-3,pf-search-col-4,pf-sc-5,pf-sc-6,pf-sc-7,pf-search-col-8"
				keepSaved="true" id="resultTable" var="result" rows="20">

				<!-- 				
				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink action="#{personaFisicaSearchingBean.sort}" 
		                		execute="@this" 
		                		value="#{messages.personaFisicaSearchTipoDocument}" 
		                    	render="resultTable">
		                        <f:param name="sortProperty" value="tipoDocumento" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['tipoDocumento']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['tipoDocumento']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>	
					</f:facet>
					<h:outputText value="#{messages[result.tipoDocumento.label]}" />
				</h:column>
 				-->	
				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.personaSearchNumeroDocumento}" 
		                    	render="resultTable"
		                        action="#{personaFisicaSearchingBean.sort}">
		                        <f:param name="sortProperty" value="numeroDocumento" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['numeroDocumento']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['numeroDocumento']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>	
					</f:facet>
					
					<h:commandLink action="#{personaFisicaBean.showRead}" 
						immediate="true">
						<h:outputText value="#{result.numeroDocumento}" >
							<f:convertNumber type="number" groupingUsed="true" />
						</h:outputText>	
						<f:setPropertyActionListener target="#{personaFisicaBean.id}" 
							value="#{result.id}" />
						<f:setPropertyActionListener target="#{personaFisicaBean.persistReturnView}" 
							value="#{facesContext.viewRoot.viewId}"  />
						<f:setPropertyActionListener target="#{personaFisicaBean.cancelView}" 
							value="#{facesContext.viewRoot.viewId}"  />
					</h:commandLink>
				</h:column>
						
				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.personaSearchApellido1}" 
		                    	render="resultTable"
		                        action="#{personaFisicaSearchingBean.sort}">
		                        <f:param name="sortProperty" value="apellido1" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['apellido1']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['apellido1']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>
					</f:facet>
					
					<h:outputText value="#{result.apellido1}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.personaSearchApellido2}" 
		                    	render="resultTable"
		                        action="#{personaFisicaSearchingBean.sort}">
		                        <f:param name="sortProperty" value="apellido2" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['apellido2']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['apellido2']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>
					</f:facet>
					<h:outputText value="#{result.apellido2}" />
				</h:column>
	
				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.personaSearchPrimeroNombre}" 
		                    	render="resultTable"
		                        action="#{personaFisicaSearchingBean.sort}">
		                        <f:param name="sortProperty" value="primerNombre" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['primerNombre']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['primerNombre']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>
					</f:facet>
					<h:outputText value="#{result.primerNombre}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.personaSearchSegundoNombre}" 
		                    	render="resultTable"
		                        action="#{personaFisicaSearchingBean.sort}">
		                        <f:param name="sortProperty" value="segundoNombre" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['segundoNombre']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['segundoNombre']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>
					</f:facet>

					<h:outputText value="#{result.segundoNombre}" />
				</h:column>
	
				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.personaSearchSexo}" 
		                    	render="resultTable"
		                        action="#{personaFisicaSearchingBean.sort}">
		                        <f:param name="sortProperty" value="sexo" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['sexo']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{personaFisicaSearchingBean.sortsOrders['sexo']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>
					</f:facet>
					<h:outputText value="#{messages[result.sexo.label]}" />
				</h:column>
	
	            <h:column>
					<f:facet name="header">
						<h:outputText value="#{messages.actiones}" />
					</f:facet>
					<h:commandLink action="#{personaFisicaBean.showUpdate}"
						immediate="true">
						<i class="icon-edit" title="#{messages.edit}"></i>
						<f:setPropertyActionListener target="#{personaFisicaBean.id}" 
							value="#{result.id}" />
						<f:setPropertyActionListener target="#{personaFisicaBean.persistReturnView}" 
							value="#{facesContext.viewRoot.viewId}"  />
						<f:setPropertyActionListener target="#{personaFisicaBean.cancelView}" 
							value="#{facesContext.viewRoot.viewId}"  />
					</h:commandLink>
					<h:commandLink action="#{personaFisicaBean.showDelete}"
						immediate="true">
						<i class="icon-remove" title="#{messages.remove}"></i>
						<f:setPropertyActionListener target="#{personaFisicaBean.id}" 
							value="#{result.id}" />
						<f:setPropertyActionListener target="#{personaFisicaBean.persistReturnView}" 
							value="#{facesContext.viewRoot.viewId}"  />
						<f:setPropertyActionListener target="#{personaFisicaBean.cancelView}" 
							value="#{facesContext.viewRoot.viewId}"  />
					</h:commandLink>
	            </h:column>			

				<f:facet name="footer">
					<rich:dataScroller id="scroller" renderIfSinglePage="false"
						stepControls="show"
						fastControls="hide"
						styleClass="pagination"
						for="resultTable" maxPages="10">
					</rich:dataScroller>
				</f:facet>								
			</rich:dataTable>
			
			<div class="form-actions">
				<h:commandLink action="#{personaFisicaBean.exportToExcel}"
					styleClass="btn btn-primary"
					immediate="true">
					<i class="icon-download-alt" title="#{messages.exportToExcel}"></i>				
					<h:outputText value=" #{messages.exportToExcel}" />
				</h:commandLink>
				
				<h:link outcome="create"
					style="margin-left:5px;"
					styleClass="btn btn-info">
					<i class="icon-file" title="#{messages.personaFisicaCreate}"></i>				
					<h:outputText value=" #{messages.personaFisicaCreate}" />
				</h:link>
			</div>
		</h:form>		
	</ui:define>
</ui:composition>